package com.ccom.ccomstart;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * @Description:
 * @auther: jjzhang24
 * @date: 2021年12月13日
 */
@RunWith(SpringRunner.class)
//指定web环境，随机端口
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class ControllerTest1 {
    @Autowired
    private TestRestTemplate testRestTemplate;

    @Test
    public void test1() {
        String context = testRestTemplate.getForObject("/hello/test", String.class);
        Assert.assertEquals("hello test", context);
    }
}
